﻿//name:trader.cpp
//who: by Jack Chen
//what: just make a logic for worried trader

#include <trader.h>

//'inherit MONSTER ;      //this line is not necessary since we already assign it in trader.h
                          //You can remove this line in the next revision


void Trader::nowwhat() //indicate how far the player have been done or not
{
    if(quest_accepted) //if this player has been accept, then check items required
    {
        //trader::check_items()
        this->check_items();        //this = a pointer to the trader object, so here we use "->"
    }
	
    if(quest_isnt_accept) //if this player hasn't accept yet, ask for accept
    {
        write("@MATT
進口的進口的高級白杉木被小乞丐群給偷走了, 找了好多人去尋找都無法拿回
現在無法對皇室神殿交代,怎麼辦才好呢?你能幫我找回嗎(accept)?  // 如果玩家沒處碰任務過, 顯示的觸發
MATT");
    }
	
    if(quest_have_been_finished) //if this player has been finished this quest, thanks for him or her
    {
        write("謝謝這位大大,還好有您的幫忙押");  // 當這任務解過後 玩家輸入ask trader about problem 
    }
}


void Trader::check_items() //check items that required to get into vagrant's village
{
    if(this_player_has_vagrant_cloak && doesnt_have_a_boat)
    {
        return "你還缺少小船一艘, 沒有小船無法進到他們集會所." // 如果玩家沒有船
    }
	
    if(this_player_have_a_boat && vagrant_cloak)
    {
        return @MATT
你已經拿到外袍跟小船了嗎.真是太好了!他們有密道小船可以行駛在三角洲中
的小河道上,外袍記得要披著, 偽裝成乞丐比較不會被懷疑."
MATT;
    }
	
    if(this_player_doesn''t_have_a_cloak)
    {
        return "你沒準備乞丐穿的外袍的話是混不進去裡面的."; //如果玩家沒有乞丐袍
    }
}

// ====================================================================================================================================
// ====================================================================================================================================

/* "trigger__ means this member function is an event only happens when specific criteria met, pretty much like a trigger
   "input_"   indicates this mf is obtained from the user's input (因為使用者的"輸入"行為產生的 mf, 加上 input_ 字樣)
   (ps. mf = member function(s), ma = member attribute(s) )
*/

void Trader::trigger__input_askMatter()
{
    string input;
    std::cin >> input;
    //return (input.lowercase() == "ask trader about matter") ? true : false;
    if (input.lowercase() == "ask trader about matter")
        this->nowwhat();
}

bool Trader::trigger__input_askAmIHandsome(Player* player)
{
    string input;
    std::cin >> input;
    return ((player->name == "vocab") && (input.lowercase() == "am i handsome")) ? true : false;
}

void Trader::trigger__input_accept()
{
    string input;
    std::cin >> input;
    if (input == "accept")
        // code goes here..... (still in main.c)
}      